<?php
class AdmContentAction extends admCommonAction
{
	/**
	 * @var menuLib
	 */
	private $menuLib;
	
	function __construct()
	{
		parent::__construct();
		$this->menuLib=new menuLib();
	}
	
	public function addmenu()
	{
		$data=array();
		$data['parentId']=wsRoute::segment(3,0);
		if($_POST)
		{
			$mname=$this->checkFormItem('str','mname','标题长度错误');
			$cname=$this->checkFormItem('strEn','cname','别名只能是英文、数字、-符号组成');
			$menuType=$this->checkFormItem('int','contentType','栏目类型错误',1,2);
			$showSub=$this->checkFormItem('int','showSub','是否选择显示子栏目内容',1,2,'post#');
			$parentId=$this->checkFormItem('int','parentId','上级ID错误',1,wsForm::$intMax,'post#');
			try
			{
				$data['add']=$this->menuLib->addMenu($mname, $cname, $menuType,$showSub,$parentId) ?'添加成功' :'添加失败';
			}
			catch (Exception $e)
			{
				$this->error($e->getMessage());
			}
		}
		$this->loadView('adm_menu_add',$data);
	}
	
	public function adminmenu()
	{
		$menuList=$this->menuLib->getMenuList();
		$this->loadView('adm_menu',array('menuList'=>$menuList));
	}
}